//
//  YTHcollectionheader.m
//  qiyunapp
//
//  Created by qiyun on 2018/7/14.
//  Copyright © 2018年 qiyun. All rights reserved.
//

#import "YTHcollectionheader.h"

@implementation YTHcollectionheader
+ (NSString *)headerViewIdentifier{
    static NSString *footerIdentifier = @"footerViewIdentifier";
    return footerIdentifier;
}
+ (instancetype)headerViewWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath
{
    //从缓存池中寻找底部视图对象，如果没有，该方法自动调用alloc/initWithFrame创建一个新的底部视图返回
    YTHcollectionheader *headerView =
    [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[YTHcollectionheader headerViewIdentifier] forIndexPath:indexPath];
    return headerView;
}
/* 注册了底部视图后，当缓存池中没有底部视图的对象时候，自动调用alloc/initWithFrame创建 */
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {

        UIImageView*loveicon=[[UIImageView alloc]init];
        loveicon.image=IMAGE(@"smallicon");
        [self addSubview:loveicon];
        loveicon.frame=CGRectMake(12, 12, 16, 14);
        self.loveicon = loveicon;
        //
        UILabel*textLabel=[[UILabel alloc]init];
        textLabel.text=@"更多资讯";
        textLabel.font=KFONT_medium(13);
        textLabel.textColor=RGBA(144, 144, 144);
        [self addSubview:textLabel];
        textLabel.frame=CGRectMake(CGRectGetMaxX(loveicon.frame)+7, 12, 100, 13);
        self.textLabel = textLabel;
    }
    return self;
    
}
@end
